<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="layui/css/layui.css"  media="all">

    <script src="js/jquery/jquery.min.js"></script>
    <script src="layui/layui.js" charset="utf-8"></script>
</head>
<body>
 <h2>
     输出结果为
 </h2>

 <div>
     <table class="table">
         <caption style="text-align: center;letter-spacing: 20px;font-size: 35px;font-weight: bolder">员工信息表</caption>
         <thead>
         <tr class="danger">
             <th>姓名</th>
             <th>部门名称</th>
             <th>工作</th>
             <th>薪资</th>
             <th>操作</th>
         </tr>
         </thead>
         <tbody  id="allEmpMessage">
         </tbody>
     </table>
     <div id="emplimit" style="margin-top: 10px;margin-left: 20%"></div>
 </div>

<script>

               $(function () {
                   var count=10;
                   var getEmpList = function(obj){
                       $.ajax({
                           url:"allemp.action",
                           type:"POST",
                           data:{
                               pageIndex:obj.curr||1,
                               pageSize:obj.limit,
                           },
                           datatype:"json",
                           success:function (data) {
                               $("#allEmpMessage").find(".success").remove();
                               $.each(data.empList,function (index,emp) {
                                   var trnode = "<tr class='success'><td>"+emp.ename+"</td><td>"+emp.dept.dname+"</td><td>"+
                                       emp.job+"</td><td>"+emp.sal+"</td><td>"+"<a href='searchempbyid.action?emp.empid="+emp.empid +"'>"+"修改 &nbsp &nbsp"+"</a><a href='deleteemp.action?emp.empid="+emp.empid +"'>"+"删除"+
                                       "</a></td></tr>"
                                   $("#allEmpMessage").append(trnode);
                               })
                               count = data.counts;
                               console.log(count)
                           }

                       })
                   }

                   layui.use(['laypage','layer'],function () {

                       var laypage=layui.laypage;
                       //完整板分页功能
                       laypage.render({
                           elem:'emplimit',
                           count:count||10,
                           limit:1,
                           first:'首页',
                           last:'尾页',
                           prev:'<',
                           next:'>',
                           layout:['count','first','prev','page','next','last','skip'],
                           jump:function (obj) {
                               getEmpList(obj);
                           }
                       })
                   })

               })


</script>
</body>
</html>
